package cn.qingsec.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;

public class redissonConfig {
    @Value("${spring.redis.host}")
    private String redisHost;
    @Value("${spring.redis.port}")
    private String redisPort;

    @Value("${spring.redis.database}")
    private String redisDatabase;
//    @ConditionalOnMissingBean
//    @Primary
//    @Bean
//    public RedissonClient redissonClient() {
//        Config config = new Config();
//        // 单节点模式
//        SingleServerConfig singleServerConfig = config.useSingleServer();
//        singleServerConfig.setAddress("redis://"+redisHost+":"+redisPort);
//        singleServerConfig.setDatabase(Integer.getInteger(redisDatabase));
//        // 使用json序列化方式
//        Codec codec = new JsonJacksonCodec();
//        config.setCodec(codec);
//        RedissonClient redissonClient = Redisson.create(config);
//        return redissonClient;
//    }
}
